<?php

require_once 'Core/Form.php';

class Admin_Form_GroupAcl extends Core_Form
{
    /**
     * The name of the group
     *
     * @var string
     */
    protected $_groupName;

    /**
     * Initialize the form
     *
     * @return void
     */
    public function init()
    {
        parent::init();

        $view = $this->getView();

        $hidden = $this->createElement('hidden', 'name');

        $groups = $view->selectGroup('from_groupname', null, null, $this->_groupName, 'superadmin');

        $submit = $this->createElement('submit', 'update', array(
            'label'     => $view->getTranslation('Copy Permissions'),
            'attribs'   => array('class' => 'submit'),
        ));

        $this->addElement($hidden)
             ->addElement($groups)
             ->addElement($submit)
             ->setAttribs(array('class' => 'padding-10'));
    }

    public function setGroupName($groupName)
    {
        $this->_groupName = $groupName;

        $this->getElement('name')->setValue($this->_groupName);
        $this->getElement('from_groupname')->removeMultiOption($this->_groupName);
    }
}